/**
 * 
 */
package UI;

import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;

import org.dyno.visual.swing.layouts.Constraints;
import org.dyno.visual.swing.layouts.GroupLayout;
import org.dyno.visual.swing.layouts.Leading;

import HelloWorld.HelloWorld;

//VS4E -- DO NOT REMOVE THIS LINE!
public class MainWindow extends JFrame 
{

	/**
	 * @param textField the textField to set
	 */

	private static final long serialVersionUID = 1L;
	private JButton button_1;
	private JTextField textField;
	private static final String PREFERRED_LOOK_AND_FEEL = "javax.swing.plaf.metal.MetalLookAndFeel";
	public MainWindow() 
	{
		initComponents();
	}

	private void initComponents() {
		setLayout(new GroupLayout());
		add(getJButton0(), new Constraints(new Leading(87, 10, 10), new Leading(58, 12, 12)));
		add(getJTextField0(), new Constraints(new Leading(81, 83, 12, 12), new Leading(103, 12, 12)));
		setSize(320, 240);
	}

	
	private JTextField getJTextField0() {
		if (textField == null) {
			textField = new JTextField();
			textField.setFont(new Font("Dialog", Font.PLAIN, 14));
			textField.setToolTipText("Your message");
		}
		return textField;
	}
	

	private JButton getJButton0() {
		if (button_1 == null) {
			button_1 = new JButton();
			button_1.setText("Button");
			button_1.setToolTipText("Press to see private message");
			button_1.addActionListener(new ActionListener() 
			{
	
				public void actionPerformed(ActionEvent event) 
				{
					button_1ActionActionPerformed(event);
				}
			});
		}
		return button_1;
	}

	private static void installLnF() 
	{
		try {
			String lnfClassname = PREFERRED_LOOK_AND_FEEL;
			if (lnfClassname == null)
				lnfClassname = UIManager.getCrossPlatformLookAndFeelClassName();
			UIManager.setLookAndFeel(lnfClassname);
		} catch (Exception e) {
			System.err.println("Cannot install " + PREFERRED_LOOK_AND_FEEL
					+ " on this platform:" + e.getMessage());
		}
	}

	/**
	 * Main entry of the class.
	 * Note: This class is only created so that you can easily preview the result at runtime.
	 * It is not expected to be managed by the designer.
	 * You can modify it as you like.
	 */
	public static void main(String[] args) {
		installLnF();
		SwingUtilities.invokeLater(new Runnable() {
			@Override
			public void run() {
				MainWindow frame = new MainWindow();
				frame.setDefaultCloseOperation(MainWindow.EXIT_ON_CLOSE);
				frame.setTitle("MainWindow");
				frame.getContentPane().setPreferredSize(frame.getSize());
				frame.pack();
				frame.setLocationRelativeTo(null);
				frame.setVisible(true);
			}
		});
	}

	private void button_1ActionActionPerformed(ActionEvent event) 
	{
		//Create an instance of object HelloWorld
		HelloWorld helloWorld = new HelloWorld();
		String str = helloWorld.getMessage();

		// Set the value of textField to be the return value of helloWorld 
		textField.setText(str);
	}

}
